﻿/*-----------------------------------------------
// File: BCAttackWaitState.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;

namespace Battle.View
{
    public class BCAttackWaitState : Fsm.FsmStateMonoBase<ActorState> 
    {
        BattleCharacter bc {
            get { return this.controller as BattleCharacter; }
        }
        public BCAttackWaitState(ActorState state, BattleCharacter ctrl) : base(state, ctrl) { }


        float deltaTime = 0f;
        public float attackWaitTimeOut {
            get { return Dict.Blo.DictConfigBlo.GetAttackWaitTimeOut(); }
        }
        public override void Enter()
        {
            if (!bc.IsFirstSkillCanCast() && !bc.IsSecondSkillCanCast())
            {
                deltaTime = attackWaitTimeOut;
            }
            else {
                deltaTime = 0f;
            }
            bc.PlayStand();

            BattleViewCtrl.GetInstance().OnBattleCharacterEnterAttackWaitState(bc);
        }
        public override void Update()
        {
            deltaTime += Time.deltaTime;

            if (bc.IsHavePackageNeedDo()) {
                var package = bc.DequeuePackage();
                bc.DoPackage(package);
                return;
            }

            if (deltaTime >= attackWaitTimeOut) {
                bc.SwitchState(ActorState.AttackMoveBackward);
                return;
            }
        }
        public override void Leave()
        {
            bc.isHealer = false;
        }
    }

}